<template>
	<a-config-provider :locale="locale">
		<div id="app">
			<a-select 
				default-value="zh" 
				style="width: 120px" 
				@change="handleChange">
				<a-select-option 
					v-for="(val, i) in langs"
					:value="val.value"
					:key="i">
					{{ val.name }}
				</a-select-option>
			</a-select>
			<div id="nav">
				<router-link to="/">Home</router-link> |
				<router-link to="/about">About</router-link>
			</div>
			<router-view/>
		</div>
	</a-config-provider>
</template>

<script>
import zh_CN from 'ant-design-vue/lib/locale-provider/zh_CN';

export default {
	data() {
		return {
			langs: [
				{name: '简体中文', value: 'zh'},
				{name: 'English', value: 'en'},
			],
			locale: zh_CN,
			localLevel: 'zh',
		}
	},
	methods: {
		handleChange(value) {
			this.localLevel = value;
			if (value === this.langs[0].value) {
				this.locale = zh_CN;
			} else if (value === this.langs[1].value) {
				this.locale = null;
			}
			this.$i18n.locale = value;
		},
	},
}
</script>

<style lang="less">
@import '~ant-design-vue/dist/antd.less';
@import './assets/variable.less';

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
